#ifndef _MAP_MANAGER_
#define _MAP_MANAGER_

#include <stdio.h>
#include "Common.h"

#define MAP_TYPE_FLOOR 0
#define MAP_TYPE_WALL  1

#define MAP_STATE_MOVE   -1
#define MAP_STATE_FREE   0
#define MAP_STATE_WORKER 1
#define MAP_STATE_WALL   2
#define MAP_STATE_OBJECT 3

#define MapCoord(x, y) (y * map->width + x)

typedef struct
{
    int width;
    int height;

    unsigned char* data;
    char* state;

	BITMAP* layers[2];
} Map;

extern Map*  map;
extern Mutex mapMutex;

void LoadMap(FILE* file);
void GenerateMapBmp(Map* m);
COORD GetRandomFreePosition();

int GetMapIndexByXY(int x, int y);
int GetMapIndexByCoord(COORD coord);

#endif
